<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>DOM查询</title>
    <style type="text/css">
        div, span, p {
            width: 140px;
            height: 140px;
            margin: 5px;
            background: #aaa;
            border: #000 1px solid;
            float: left;
            font-size: 17px;
            font-family: Verdana;
        }

        div.mini {
            width: 55px;
            height: 55px;
            background-color: #aaa;
            font-size: 12px;
        }

        div.hide {
            display: none;
        }
    </style>
    <script type="text/javascript" src="../jquery-1.7.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            function anmateIt(){
                $("#mover").slideToggle("slow", anmateIt);
            }
            anmateIt();
        $("#btn1").click(function(){
            $("div").eq(3).css("background","#bbffaa");
        });
            $("#btn2").click(function(){
                $("div").first().css("background","#bbffaa");
            });
            $("#btn3").click(function(){
                $("div").last().css("background","#bbffaa");
            });
            $("#btn4").click(function(){
                $("div").filter(":even").css("background","#bbffaa");
            });
            $("#btn5").click(function(){
                alert($("#one").is(":empty"));
            });
            $("#btn6").click(function(){
                $("div").has(".mini").css("background","#bbffaa");
            });
            $("#btn7").click(function(){
                $("div").not(".one").css("background","#bbffaa");
            });
            $("#btn8").click(function(){
                $("body").children("div.one").css("background","#bbffaa");
            });
            $("#btn9").click(function(){
                $("body").find("div.mini").css("background","#bbffaa");
            });
            $("#btn10").click(function(){
                $("#one").next("div").css("background","#bbffaa");
            });
            $("#btn11").click(function(){
                $("#one").nextAll("span").css("background","#bbffaa");
            });
            $("#btn12").click(function(){
                $("#one").nextUntil("span").css("background","#bbffaa");
            });
            $("#btn13").click(function(){
                $(".mini").parent().css("background","#bbffaa");
            });
            $("#btn14").click(function(){
                $("#two").prev("div").css("background","#bbffaa");
            });
            $("#btn15").click(function(){
                $("span").prevAll("div").css("background","#bbffaa");
            });
            $("#btn16").click(function(){
                $("span").prevUntil("#one").css("background","#bbffaa");
            });
            $("#btn17").click(function(){
                $("#two").siblings().css("background","#bbffaa");
            });
            $("#btn18").click(function(){
                $("span").add("#one").add("#two").css("background","#bbffaa");
            });
        });


    </script>
</head>
<body>
<input type="button" value="eq()选择索引值为等于 3 的 div 元素" id="btn1" />
<input type="button" value="first()选择第一个 div 元素" id="btn2" />
<input type="button" value="last()选择最后一个 div 元素" id="btn3" />
<input type="button" value="filter()在div中选择索引为偶数的" id="btn4" />
<input type="button" value="is()判断#one是否为:empty或:parent" id="btn5" />
<input type="button" value="has()选择div中包含.mini的" id="btn6" />
<input type="button" value="not()选择div中class不为one的" id="btn7" />
<input type="button" value="children()在body中选择所有class为one的div子元素" id="btn8" />
<input type="button" value="find()在body中选择所有class为mini的div后代元素" id="btn9" />
<input type="button" value="next()#one的下一个div" id="btn10" />
<input type="button" value="nextAll()#one后面所有的span元素" id="btn11" />
<input type="button" value="nextUntil()#one和span之间的元素" id="btn12" />
<input type="button" value="parent().mini的父元素" id="btn13" />
<input type="button" value="prev()#two的上一个div" id="btn14" />
<input type="button" value="prevAll()span前面所有的div" id="btn15" />
<input type="button" value="prevUntil()span向前直到#one的元素" id="btn16" />
<input type="button" value="siblings()#two的所有兄弟元素" id="btn17" />
<input type="button" value="add()选择所有的 span 元素和id为two的元素" id="btn18" />


<h3>基本选择器.</h3>
<br /><br />
文本框<input type="text" name="account" disabled="disabled" />
<br><br>
<div class="one" id="one">
    id 为 one,class 为 one 的div
    <div class="mini">class为mini</div>
</div>
<div class="one" id="two" title="test">
    id为two,class为one,title为test的div
    <div class="mini" title="other"><b>class为mini,title为other</b></div>
    <div class="mini" title="test">class为mini,title为test</div>
</div>

<div class="one">
    <div class="mini">class为mini</div>
    <div class="mini">class为mini</div>
    <div class="mini">class为mini</div>
    <div class="mini"></div>
</div>
<div class="one">
    <div class="mini">class为mini</div>
    <div class="mini">class为mini</div>
    <div class="mini">class为mini</div>
    <div class="mini" title="tesst">class为mini,title为tesst</div>
</div>
<div style="display:none;" class="none">style的display为"none"的div</div>
<div class="hide">class为"hide"的div</div>
<span id="span1">^^span元素 111^^</span>
<div>
    包含input的type为"hidden"的div<input type="hidden" size="8">
</div>
<span id="span2">^^span元素 222^^</span>
<div id="mover">正在执行动画的div元素.</div>
</body>
</html>

